package cn.consult.sys.service.impl;

import cn.consult.sys.entity.TDwellEmployee;
import cn.consult.sys.service.TMeterReadingRecordService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.consult.sys.dao.TMeterReadingRecordDao;
import cn.consult.sys.entity.TMeterReadingRecord;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * (TMeterReadingRecord)表服务实现类
 *
 * @author makejava
 * @since 2024-04-16 09:17:59
 */
@Service("tMeterReadingRecordService")
public class TMeterReadingRecordServiceImpl extends ServiceImpl<TMeterReadingRecordDao, TMeterReadingRecord> implements TMeterReadingRecordService {


    @Autowired
    TMeterReadingRecordDao tMeterReadingRecordDao;

    @Override
    public PageInfo<TMeterReadingRecord> selectPages(Map<String, Object> params) {
        int pageNum = Integer.parseInt(params.get("pageNum").toString());
        int pageSize = Integer.parseInt(params.get("pageSize").toString());
        PageHelper.startPage(pageNum, pageSize, "id desc");
        LambdaQueryWrapper<TMeterReadingRecord> readingRecord = new LambdaQueryWrapper<>();
        readingRecord.eq(params.get("number") != null && params.get("number") != "", TMeterReadingRecord::getNumber, params.get("number"));
        readingRecord.eq(TMeterReadingRecord::getRecordType, params.get("type"));
        List<TMeterReadingRecord> tMeterReadingRecords = tMeterReadingRecordDao.selectList(readingRecord);
        PageInfo<TMeterReadingRecord> appInfoPageInfo = new PageInfo<>(tMeterReadingRecords);
        return appInfoPageInfo;
    }
}

